package com.matrix.java.chap_03;

import java.util.Scanner;

/**
 * @author ffy
 * @since 2021-10-18-10:24
 */
public class Ex3_01 {
    public static void main(String[] args) {
        System.out.print("Enter a,b,c: ");
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double c = scanner.nextDouble();
        double equa = Math.pow(b, 2) - 4 * a * c;
        if (equa < 0) {
            System.out.println("The equation has no roots");
        }
        if (equa == 0) {
            double r = -b / (2 * a);
            System.out.println("The equation has one roots " + r);
        } else {
            double r1 = (-b - Math.pow(equa, 0.5)) / (2 * a);
            double r2 = (-b + Math.pow(equa, 0.5)) / (2 * a);
            System.out.println("The equation has two roots " + r1 + " and " + r2);
        }
        scanner.close();
    }
}
